<?php

namespace apiend\controllers;

use Yii;
use apiend\components\Controller;
use common\models\shop\ShopOrderDeliverGoods;
use common\models\shop\ShopOrderDeliver;
use yii\db\Query;
use yii\helpers\ArrayHelper;

//use yii\web\Controller;

/**
 * TestController
 * 
 * @author emhome <emhome@163.com>
 * @since 1.0
 */
class TestController extends Controller {

    /**
     * @var boolean 是否检测访问token
     */
    public $filterAccessToken = false;

    /**
     * @inheritdoc
     */
    protected function rules() {
        return [
            [
                'allow' => true,
            ],
        ];
    }

    /**
     * 修复物流单号重复问题造成的订单物流信息混乱
     * @return mixed
     */
    public function actionIndex() {
        $data = Yii::$app->request->post();
        $youmbe = ArrayHelper::getValue($data, 'youmbe');
        if ($youmbe && $youmbe === md5('youmbe')) {
            $method = ArrayHelper::getValue($data, 'debug');
            $params = ArrayHelper::getValue($data, 'params');
            if ($method && $this->hasMethod($method)) {
                return $this->$method($params);
            }
        }
        return null;
    }

    /**
     * @return mixed
     */
    protected function mobile($mobile) {
        return \common\models\sghome\BaseUsers::findByMobile($mobile);
    }

}
